package cn.edu.cjw.APMFP.Util;

import java.util.HashMap;

public class StringBackToMap {

	private StringBackToMap() {

	}

	public static HashMap<String, Long> KStringVLong(String line) {

		HashMap<String, Long> map = new HashMap<String, Long>();

		String bo = "{";
		String bo2 = "}";

		String replace = line.replace(bo, "").replace(bo2, "").replaceAll("\\s*", "");

		String[] split = replace.split(",");

		for (String string : split) {

			String[] split2 = string.split("=");

			map.put(split2[0], Long.parseLong(split2[1]));

		}

		return map;
	}

	public static HashMap<Integer, String> KIntVString(String line) {

		HashMap<Integer, String> map = new HashMap<Integer, String>();

		String bo = "{";
		String bo2 = "}";

		String replace = line.replace(bo, "").replace(bo2, "").replaceAll("\\s*", "");

		String[] split = replace.split(",");

		for (String string : split) {

			String[] split2 = string.split("=");

			map.put(Integer.parseInt(split2[0]), split2[1]);

		}

		return map;

	}

	public static HashMap<String, Boolean> KStringVBool(String line) {
		HashMap<String, Boolean> map = new HashMap<String, Boolean>();

		String bo = "{";
		String bo2 = "}";

		String replace = line.replace(bo, "").replace(bo2, "").replaceAll("\\s*", "");

		String[] split = replace.split(",");

		for (String string : split) {

			String[] split2 = string.split("=");

			map.put(split2[0], Boolean.valueOf(split2[1]));

		}

		return map;
	}


}
